import { Module, Global } from '@nestjs/common';
import { config } from '../../config/index';
import { RabbitMQModule } from '@golevelup/nestjs-rabbitmq';

@Global()
@Module({
	exports: [RabbitMQModule],
	imports: [
		RabbitMQModule.forRootAsync(RabbitMQModule, {
			useFactory: () => {
				return {
					exchanges: [
						{
							name: 'crypto',
							type: 'direct',
						},
					],
					uri: config.rabbitmq.url,
					connectionInitOptions: { wait: false },
				};
			},
		}),
	],
})
export class RabbitModule {}
